<template>
  <div>
    
     <!-- 作业2 -->
    <div>
       <h3>作业2</h3>
    <ul>
      <li v-for="(item,index) in list" :key="index">
        {{item}} <button @click="deletefn(index)">删除</button>
      </li>
    </ul>
      <button @click="addfn">生成</button>
    <hr>
    </div>
    
    
  </div>
</template>

<script>
export default {
  

  data() {
    return {
      list:[1,5,3]
    };
  },

  mounted() {
    
  },

  methods: {
   
    addfn(){
      this.list.push(Math.floor(Math.random()*10))
    },
    deletefn(index){
      this.list.splice(index,1)
    }
  },
};
</script>

<style lang="scss" scoped>

</style>